﻿package jokers{
	import jokers.*;
	import flash.display.MovieClip;
	
    public class JCrystal { 
		public static const CRYSTAL_DES:int = 64;
	
		public static const CRYSTAL_1:int = 0;
		public static const CRYSTAL_2:int = 1;
		public static const CRYSTAL_3:int = 2;
		public static const CRYSTAL_4:int = 3;
		public static const CRYSTAL_5:int = 4;
		public static const CRYSTAL_6:int = 5;
		public static const CRYSTAL_7:int = 6;
		public static const CRYSTAL_IRON:int = 7;
		
		public static const CRYSTAL_C_YELLO:int = 0;
		public static const CRYSTAL_C_WHITE:int = 1;
		public static const CRYSTAL_C_BLUE:int = 2;
		public static const CRYSTAL_C_RED:int = 3;
		public static const CRYSTAL_C_PINK:int = 4;
		public static const CRYSTAL_C_ORANGE:int = 5;
		public static const CRYSTAL_C_GREEN:int = 6;
		
		public static const STATE_NORMAL:int = 0;
		public static const STATE_EXCHANGING:int = 1;
		public static const STATE_DELETE:int = 2;
		public static const STATE_FALLDOWN:int = 3;
		public static const STATE_FALLPRE:int = 4;
		
		public static function initCrystal(mc:MovieClip):void{
			mc.sta = STATE_NORMAL;
			mc.gotoAndStop(1);
		}
		
		public static function getCrystalType(mc:MovieClip):int{
			if(mc is Crystal1) return CRYSTAL_1;
			if(mc is Crystal2) return CRYSTAL_2;
			if(mc is Crystal3) return CRYSTAL_3;
			if(mc is Crystal4) return CRYSTAL_4;
			if(mc is Crystal5) return CRYSTAL_5;
			if(mc is Crystal6) return CRYSTAL_6;
			if(mc is Crystal7) return CRYSTAL_7;
			if(mc is Iron) return CRYSTAL_IRON;
			return -1;
		}
		
		public static function getCrystal(id:int):MovieClip{
			var crystal:MovieClip;
			
			switch(id){
				case CRYSTAL_1:
				crystal = new Crystal1();
				break;
				case CRYSTAL_2:
				crystal = new Crystal2();
				break;
				case CRYSTAL_3:
				crystal = new Crystal3();
				break;
				case CRYSTAL_4:
				crystal = new Crystal4();
				break;
				case CRYSTAL_5:
				crystal = new Crystal5();
				break;
				case CRYSTAL_6:
				crystal = new Crystal6();
				break;
				case CRYSTAL_7:
				crystal = new Crystal7();
				break;
				case CRYSTAL_IRON:
				crystal = new Iron();
				break;
			}
			
			initCrystal(crystal);
			
			return crystal;
		}
	}
}